package com.hopu.config;


import com.hopu.interceptor.LoginIntercepter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Bean("loginIntercepter")
    public LoginIntercepter loginIntercepter(){
    return new LoginIntercepter();
    }
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
    //把已经实例化的bean加载进拦截器,必须是实现HandlerInterceptor接口的拦截器
    registry.addInterceptor(loginIntercepter());
    }
}
